<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
                      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html">
<body>
    <ui:composition template="/WEB-INF/template.xhtml">
        <ui:define name="topnav">
            <ui:include src="/WEB-INF/incl/store_nav.xhtml">
                <ui:param name="page" value="cart" />
            </ui:include>
        </ui:define>

        <ui:define name="sidebar">
            <ui:include src="/WEB-INF/incl/login.xhtml" />
        </ui:define>

        <ui:define name="body">
            <f:subview id="no_order" rendered="#{completedOrder == null}">
                <p>Your order could not be completed.</p>

                <h:form id="NoOrderForm">
                    <h:commandButton id="ContinueShoppingButton" action="browse" value="Continue Shopping" />
                </h:form>
            </f:subview>
            
            <f:subview id="orderdetail" rendered="#{completedOrder != null}">
                <h2>#{messages.checkoutCompleteHeader}</h2>
                <h:form id="OrderDetailForm">
                    <h:dataTable id="OrderDetailDataTable"
                                 value="#{completedOrder.orderLines}" 
                                 var="item"
                                 styleClass="dvdtable" 
                                 headerClass="dvdtablehead"
                                 rowClasses="dvdtableodd,dvdtableeven"
                                 columnClasses="dvdtablecol">
                        <h:column id="column1">
                            <f:facet id="ItemFacet" name="header">
                                <h:outputText id="ItemText" value="#{messages.cartItemColumn}" />
                            </f:facet>
                            <h:outputText id="ItemValue" value="#{item.position}" />
                        </h:column>                        
                        <h:column id="column2">
                            <f:facet id="QuantityFacet" name="header">
                                <h:outputText id="QuantityText" value="#{messages.cartQuantityColumn}" />
                            </f:facet>
                            <h:outputText id="QuantityValue" value="#{item.quantity}" />
                        </h:column>                        
                        <h:column id="column3">
                            <f:facet id="TitleFacet" name="header">
                                <h:outputText id="TitleText" value="#{messages.cartTitleColumn}" />
                            </f:facet>
                            <h:outputText id="TitleValue" value="#{item.product.title}" />
                        </h:column>                        
                        <h:column id="column4">
                            <f:facet id="ActorFacet" name="header">
                                <h:outputText id="ActorText" value="#{messages.cartActorColumn}" />
                            </f:facet>
                            <h:outputText id="ActorValue" value="#{item.product.actors[0].name}" />
                        </h:column>                        
                        
                        <h:column id="column5">
                            <f:facet id="PriceFacet" name="header">
                                <h:outputText id="PriceText" value="#{messages.cartPriceColumn}" />
                            </f:facet>
                            <h:outputText id="PriceValue" value="#{item.product.price}">
                                <f:convertNumber type="currency" currencySymbol="$" />
                            </h:outputText>
                        </h:column>                        
                    </h:dataTable>
                </h:form>
                

                <div style="width: 100%;">
                    <div class="cntInfo" style="float: right;">
                        <h:panelGrid id="CheckoutSummary" columns="2">
                            <h:outputText id="CartSubtotalText" value="#{messages.checkoutSubtotal}" />
                            <h:outputText id="CartSubtotalValue" value="#{completedOrder.netAmount}">
                                <f:convertNumber type="currency" currencySymbol="$" />
                            </h:outputText>
                            
                            <h:outputText id="CartTaxText" value="#{messages.checkoutTax}" />
                            <h:outputText id="CartTaxValue" value="#{completedOrder.tax}">
                                <f:convertNumber type="currency" currencySymbol="$" />
                            </h:outputText>
                            
                            <h:outputText id="CartTotalText" value="#{messages.checkoutTotal}" />
                            <h:outputText id="CartTotalValue" value="#{completedOrder.totalAmount}">
                                <f:convertNumber type="currency" currencySymbol="$" />
                            </h:outputText>
                        </h:panelGrid>
                    </div>
                    
                    <div style="float:clear">&#160;</div>
                </div>
                
                
                <p class="orderBox cntAlert">
                    Thank you for ordering. 
                    <h:outputText id="TotalAmountValue" value="#{completedOrder.totalAmount}"> 
                        <f:convertNumber type="currency" currencySymbol="$" />
                    </h:outputText>
                    charged was to your <h:outputText id="CreditCartType" value="#{completedOrder.customer.creditCardTypeString}" />.
                    Your order number is 
                    <h:outputText id="OrderId" value="#{completedOrder.orderId}" />.
                </p>
            </f:subview>
        </ui:define>
    </ui:composition>
</body>
</html>
